<?php
/**
 * 展示
 */
require ('conn.php');
$sel="select * from t_user order by u_id";
$query=mysqli_query($conn,$sel);
?>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>主页</title>
</head>
<body>
<div style="width: 600px;margin: auto;">
<h1>用户展示以及增删</h1>
<hr>
<form action="index2.php" method="post" enctype="multipart/form-data">
    <table  border="1px solid" style="border-collapse: collapse;margin: auto;width: 600px;">
        <tr><td>用户名</td><td><input type="text" name="username"></td></tr>
        <tr><td>邮箱</td><td><input type="text" name="email"></td></tr>
        <tr><td>性别</td>
            <td><input type="radio" name="sex" value="男">男
                <input type="radio" name="sex" value="女">女
                <input type="radio" name="sex" value="未知">未知
            </td>
        </tr>
        <tr>
            <td>省份</td>
            <td>
                <select name="province">
                    <option value="湖北省">湖北省</option>
                    <option value="上海市">上海市</option>
                    <option value="重庆市">重庆市</option>
                    <option value="湖南省">湖南省</option>
                </select>
            </td>
        </tr>
        <tr>
            <td width="300px">爱好</td>
            <td><input type="checkbox" value="篮球" name="hobby[]">篮球
            <input type="checkbox" value="读书" name="hobby[]">读书
            <input type="checkbox" value="插画" name="hobby[]">插画
            <input type="checkbox" value="编程" name="hobby[]">编程
            <input type="checkbox" value="弹琴" name="hobby[]">弹琴</td>
        </tr>
    </table>
    <input type="submit" value="新增">
</form>
<table border="1px solid" style="border-collapse: collapse;margin: auto;width: 600px;">
    <tr>
        <th>id</th>
        <th>用户名</th>
        <th>邮箱</th>
        <th>性别</th>
        <th>省份</th>
        <th>爱好</th>
        <th>操作</th>
    </tr>
    <?php
        while($row=mysqli_fetch_assoc($query)){
            ?>
        <tr>
            <td><?php echo $row['u_id'] ;?></td>
            <td><?php echo $row['u_name'] ;?></td>
            <td><?php echo $row['u_email'] ;?></td>
            <td><?php echo $row['u_sex'] ;?></td>
            <td><?php echo $row['u_province'] ;?></td>
            <td><?php echo $row['u_hobby'] ;?></td>
            <td><a onclick="return confirm('是否删除？')" href="delete.php?id=<?php echo $row['u_id'] ;?>">删除</a></td>
        </tr>
    <?php
        }

    ?>
</table>
</div>
</body>
</html>
